//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
import Mall_campsitemBox from "../../views/mall/Mall_campsitemBox.vue"
let extension = {
    components: {//动态扩充组件或组件路径
        //表单header、content、footer对应位置扩充的组件
        gridHeader: '',//{ template: "<div>扩展组xx件</div>" },
        gridBody: Mall_campsitemBox,
        gridFooter: '',
        //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
        modelHeader: '',
        modelBody: '',
        modelFooter: ''
    },
    buttons: { view: [], box: [], detail: [] },//扩展的按钮
    methods: {//事件扩展
        onInit () {
            this.$store.getters.data().viewPageTest = this;
            let list = []
            let list2 = []
            this.http.post('/api/Dictionary/GetVueDictionary', ['medal', 'CampLabelType']).then(res => {
                res.forEach(i => {
                    if (i.dicNo == "medal") {
                        list = i.data;
                    }
                    if (i.dicNo == "CampLabelType") {
                        list2 = i.data;
                    }
                })
            })
            function upMedal (params) {
                let l = params.split(',')
                let ar = []
                l.forEach(k => {
                    list.forEach(i => {
                        if (i.key == k) {
                            ar.push(i.value)
                        }
                    })
                })
                return ar.join('、')
            }
            function upLabelId (params) {
                let l = params.split(',')
                let ar = []
                l.forEach(k => {
                    list2.forEach(i => {
                        if (i.key == k) {
                            ar.push(i.value)
                        }
                    })
                })
                return ar.join('、')
            }
            this.columns.forEach(i => {
                if (i.field == 'medalId') {
                    i.render = (h, { row, column, index }) => {
                        return h(
                            "div", {},
                            row.medalId != null ? upMedal(row.medalId) : ''
                        )
                    }
                }
                if (i.field == 'labelId') {
                    i.render = (h, { row, column, index }) => {
                        return h(
                            "div", {},
                            row.labelId != null ? upLabelId(row.labelId) : ''
                        )
                    }
                }
            })
            this.columns.push({
                title: '操作',
                fixed: 'right',
                width: 100,
                render: (h, { row, column, index }) => {
                    return h(
                        "div", { style: {} }, [
                        h(
                            "a", {
                            props: {},
                            style: {},
                            on: {
                                click: (e) => {
                                    this.$refs.gridBody.openModel8(row)
                                }
                            }
                        }, "打标签"),
                    ])
                }
            })
        },
        searchAfter (result) {
            // this.columns[this.columns.length - 1] = {
            //     title: '操作',
            //     fixed: 'right',
            //     width: 100,
            //     render: (h, { row, column, index }) => {
            //         return h(
            //             "div", { style: {} }, [
            //             h(
            //                 "a", {
            //                 props: {},
            //                 style: {},
            //                 on: {
            //                     click: (e) => {
            //                         this.$refs.gridBody.openModel8(row)
            //                     }
            //                 }
            //             }, "打标签"),
            //         ])
            //     }
            // }
            
            // this.columns.push({
            //     title: '操作',
            //     fixed: 'right',
            //     width: 100,
            //     render: (h, { row, column, index }) => {
            //         return h(
            //             "div", { style: {} }, [
            //             h(
            //                 "a", {
            //                 props: {},
            //                 style: {},
            //                 on: {
            //                     click: (e) => {
            //                         this.$refs.gridBody.openModel8(row)
            //                     }
            //                 }
            //             }, "打标签"),
            //         ])
            //     }
            // })
            return true;
        },
        rowClick ({ row, column, event }) {
            this.$refs.table.$refs.table.toggleRowSelection(row);
            return true;
        },
    }
};
export default extension;